package com.fy.springmvc.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

@Controller
public class DataController {

    @RequestMapping("t1.do")
    public String test1(HttpServletRequest request, HttpSession session, HttpServletResponse... responses){
       //到request域中存数据
        request.setAttribute("name","哈哈哈");
        request.setAttribute("age","123");

        //到session中存数据
        session.setAttribute("date","2022");

        return "hello.html";
    }

    @RequestMapping("t2.do")
    public String test2(Model model){
        //到request域中存数据
        model.addAttribute("name","哈哈哈");
        model.addAttribute("age","123");


        //到session中存数据

        return "/hello.html";
    }
}
